//
//  MovieTableViewCell.m
//  豆瓣
//
//  Created by aaaaaa on 16/6/24.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "MovieTableViewCell.h"
#import "Tools.h"
#import "UIImageView+WebCache.h"
#import "MovieListModel.h"

@interface MovieTableViewCell ()

@property (nonatomic, retain) UIImageView *backgroundImageView; //蓝背景
@property (nonatomic, retain) UIImageView *movieImageView; //电影图片
@property (nonatomic, retain) UILabel *movieTitleLable; // 电影名称

@end


@implementation MovieTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createSubViews];
        
    }
    return  self;
}

- (void)createSubViews{
 
    self.backgroundImageView = [[UIImageView alloc] init];
    [self.contentView addSubview:_backgroundImageView];
    [_backgroundImageView release];
    
    self.movieImageView = [[UIImageView alloc] init];
    [self.backgroundImageView addSubview:_movieImageView];
    [_movieImageView release];
    
    self.movieTitleLable = [[UILabel alloc] init];
    [self.backgroundImageView addSubview:_movieTitleLable];
    [_movieTitleLable release];
    
    
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    self.backgroundImageView.image = IMAGE(@"bg_eventlistcell", @"png");
    self.backgroundImageView.frame = CGRectMake(10, 10, self.contentView.bounds.size.width - 20, self.contentView.bounds.size.height - 20);
    
    [self.movieImageView sd_setImageWithURL:[NSURL URLWithString:self.movieListModel.pic_url]];
    CGFloat height = [Tools getImageHeight:self.movieListModel.pic_url withWidth:self.backgroundImageView.bounds.size.width * 0.27];
    self.movieImageView.frame = CGRectMake(10, (self.contentView.bounds.size.height - 20 - height) / 2, self.backgroundImageView.bounds.size.width * 0.27, height);
    
    self.movieTitleLable.text = self.movieListModel.movieName;
    self.movieTitleLable.frame = CGRectMake(10 + self.backgroundImageView.bounds.size.width * 0.3, (self.contentView.bounds.size.height - 20 - height) / 2, self.backgroundImageView.bounds.size.width * 0.7 - 15, height);
    
}


- (void)setMovieListModel:(MovieListModel *)movieListModel{
    if (_movieListModel != movieListModel) {
        [_movieListModel release];
        _movieListModel = [movieListModel retain];
    }
    
    
    
}
















@end
